package com.diu.domain.strategy.model.entity;

import com.diu.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Date;

/**
 * @author diu
 * @description 策略实体（充血对象）
 * @create_time 2025/10/4 12:34
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class StrategyEntity {
    private Long strategyId;
    private String strategyDesc;
    private String ruleModels;

    public String[] ruleModels() {
        if (StringUtils.isBlank(ruleModels)) return null;
        return ruleModels.split(Constants.SPLIT);
    }

    public String getRuleWeight() {
        String[] ruleModels = this.ruleModels();
        if (ruleModels == null || ruleModels.length == 0) return null;
        for (String ruleModel : ruleModels) {
            if ("rule_weight".equals(ruleModel)) return ruleModel;
        }
        return null;
    }
}
